home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Programmer Disk
/
The Programmer Disk (Microforum).iso
/
xpro
/
vc
/
pro3
/
dfree3.c
< prev
next >
Wrap
Text File
|
1993-04-30
|
3KB
|
81 lines
===========================================================================
BBS: The Abacus * HST/DS * Potterville MI
Date: 04-27-93 (17:22) Number: 244
From: HENRY PIPER Refer#: 283
To: CHRIS DOWNS Recvd: NO
Subj: get disk free space Conf: (36) C Language
---------------------------------------------------------------------------
Chris Downs wrote
+-------------------------------+
###How can I get the amount of free space on a hard disk? I tried calling DO
###with function 1B. But that (or the code afterwards) sent the program into
###never never land. Could someone please provide a helpful little snippet?
###Thanks,
###
###--- GEcho 1.00
### * Origin: Kevin's Place [314-739-0571] (1:100/215)
+-------------------------------+
One snippet comming up, this is for Any Borland compiler, or Power C.
#include <stdio.h>
#include <ctype.h>
#include <dos.h>
#include <string.h>
#include <process.h>
main(int argc, char *argv[])
{
static char drivestr[5];
char tempstr[5];
static int drivenum;
long bytes_avail, bytes_total;
struct dfree data;
if (argc > 2)
{ printf("Wrong number of arguments entered.");
exit(1);
}
if(argc == 2)
{
strcpy(tempstr, argv[1]);
strupr(tempstr);
strcpy(drivestr, tempstr);
}
if (strcmp(drivestr,"A:")==0)
{ printf("\n We are checking drive A:\n");
drivenum = 1;
}
if (strcmp(drivestr,"B:")==0)
{ printf("\nWe are checking drive B:\n");
drivenum = 2;
}
if (strcmp(drivestr,"C:")==0)
{ printf("\nWe are checking drive C:\n");
drivenum = 3;
}
if (argc < 2)
{ printf("\nWe are checking the default drive.\n");
drivenum = 0;
}
getdfree(drivenum,&data);
if (data.df_sclus != 0xFFFF)
{
bytes_avail = (long) data.df_avail * data.df_bsec * data.df_sclus;
bytes_total = (long) data.df_total * data.df_bsec * data.df_sclus;
printf ("%lu Bytes Available out of a Total of %lu\n",bytes_avail,b
}
else printf("Bad data read");
}
* TLX v2.20 * The race from stupidity is to the driven, not the swift.
* SLMR 2.1 *
--- WM v2.07/91-0077
* Origin: The Boardwalk! - (206) 941-3124 - Federal Way, WA (1:343/47)
SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1
SEEN-BY: 153/752 154/40 77 157/2 159/100 125 575 950 203/23 209/209 280/1
SEEN-BY: 390/1 396/1 5 15 2270/1 2440/5 3603/20